home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * Fuzzy Brush
- * Linda McLennan
- * COPYRIGHT © 1989 Ventana Software
- */
-
- #include "BWit.h"
- #include "Fuzzy.h"
-
- pascal void main( selector, tDataPtr, refCon, returnCode )
-
- short selector;
- ToolDataPtr tDataPtr;
- Handle *refCon;
- short *returnCode;
-
- {
- DialogPtr dLogPtr;
- short itemHit;
- MenuHandle fuzzyMenu;
- FuzzyDataPtr fzDataPtr;
- EventRecord *eventDataPtr;
- char keyHit;
- GrafPtr drawingPort;
-
- *returnCode = noErr;
-
- switch( selector )
- {
- case toolAbout:
- /* show about box */
- CenterWindow('DLOG', tDataPtr->toolID );
- dLogPtr = GetNewDialog( tDataPtr->toolID, nil, (WindowPtr)behind );
- ModalDialog( nil, &itemHit );
- DisposDialog( dLogPtr );
- break;
-
- case toolSelected:
- /* tool selected from palette */
- FuzzyInit( tDataPtr, refCon );
- if ( *refCon == nil )
- *returnCode = memFullErr;
- break;
-
- case toolMenuInsert:
- /* put up menu */
- HLock( *refCon );
- fzDataPtr = (FuzzyDataPtr)**refCon;
- fuzzyMenu = fzDataPtr->theMenu;
- if ( fuzzyMenu != nil )
- {
- InsertMenu( fuzzyMenu, 0 );
- CheckItem( fuzzyMenu, fzDataPtr->whichEffect, true );
- }
- HUnlock( *refCon );
-
- DrawMenuBar();
- break;
-
- case toolDblClick:
- /* show about box */
- CenterWindow('DLOG', tDataPtr->toolID );
- dLogPtr = GetNewDialog( tDataPtr->toolID, nil, (WindowPtr)behind );
- ModalDialog( nil, &itemHit );
- DisposDialog( dLogPtr );
- break;
-
- case toolKeyDown:
- /* non-modifier key pressed */
- eventDataPtr = tDataPtr->evntRecPtr;
- keyHit = (char)(charCodeMask & (eventDataPtr->message) );
- if ( (keyHit >= '1') && (keyHit <= '3') )
- {
- HLock( *refCon );
- fzDataPtr = (FuzzyDataPtr)**refCon;
- fzDataPtr->brushSize = (keyHit - 0x0030) * 16;
- HUnlock( *refCon );
- }
- break;
-
- case toolMouseDown:
- /* mouse down, set update area empty */
- SetRect(&tDataPtr->updateRect,0,0,0,0);
- if (! tDataPtr->linePatNone)
- tDataPtr->toolActive = true;
- break;
-
- case toolStillDown:
- /* mouse still down, draw something */
- DrawEffect( tDataPtr, *refCon );
- break;
-
- case toolMouseUp:
- /* mouse up */
- SetRect(&tDataPtr->updateRect,0,0,0,0);
- tDataPtr->toolActive = false;
- break;
-
- case toolMenuEvent:
- /* select new effect */
- HLock( *refCon );
- fzDataPtr = (FuzzyDataPtr)**refCon;
- if ( tDataPtr->menuItem != fzDataPtr->whichEffect )
- {
- CheckItem( fzDataPtr->theMenu, fzDataPtr->whichEffect, false );
- CheckItem( fzDataPtr->theMenu, tDataPtr->menuItem, true );
- fzDataPtr->whichEffect = tDataPtr->menuItem;
- }
- HUnlock( *refCon );
- break;
-
- case toolMenuDelete:
- /* tool deselected, delete menu */
- DeleteMenu( tDataPtr->toolID );
- DrawMenuBar();
- break;
-
- default:
- /* just clear the update area */
- SetRect(&tDataPtr->updateRect,0,0,0,0);
- break;
-
- } /* end switch */
- }
-